<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="dian()">点我</button>
    <h3 id="result"></h3>
    <script>
        sessionStorage.setItem("name","貂蝉");
        console.log(sessionStorage.getItem("name"));


        sessionStorage.removeItem("name");
        console.log(sessionStorage.getItem("name"));

        sessionStorage.clear(); //删除所有数据
        console.log(sessionStorage.getItem("name"));

        function dian(){
            if(sessionStorage.getItem("clickCount")){
                sessionStorage.setItem("clickCount",Number(sessionStorage.getItem("clickCount"))+1);
            }else{
                sessionStorage.setItem("clickCount",1);
            }
            document.getElementById("result").innerHTML="已经点击了"+sessionStorage.getItem("clickCount")+"次";
        }
        
    </script>
</body>
</html>